// compile: g++ -o packaged_task packaged_task.cc -std=c++11
// run: ./packaged_task
#include <chrono>
#include <future>
#include <iostream>
#include <thread>

using namespace std;
int Func(int a, int b) {
  std::this_thread::sleep_for(std::chrono::seconds(3));
  return a + b;
}
void Test1() {
  std::packaged_task<int(int, int)> task(Func);
  std::future<int> fut = task.get_future();
  std::thread t1(std::move(task), 3, 5);
  cout << fut.get();
  t1.detach();
}
void Test2() {}
int main() {
  Test1();
  Test2();
  return 0;
}
